import React from 'react';
import _ from 'lodash';
import Tags from './Tags';
import NumberView from './NumberView';

export default class TextWithTags extends React.PureComponent {
  state = {};

  render() {
    const value = this.props.cellData;
    return (
      <>
        {value.text && value.textFirst ? (
          <span
            onClick={() => {
              console.log(this.props.rowData);
            }}
          >
            {value.text === 'null' ? '' : value.text}&nbsp;&nbsp;
          </span>
        ) : null}
        {(_.isNumber(value.number) || _.isArray(value.number)) && value.textFirst ? (
          <>
            <NumberView {...this.props} cellData={value.number}></NumberView>&nbsp;&nbsp;
          </>
        ) : null}
        {value.tags && value.tags.length > 0 ? (
          // <div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
          <Tags cellData={value.tags} />
        ) : // </div>
        null}
        {value.text && !value.textFirst ? value.text : null}
        {(_.isNumber(value.number) || _.isArray(value.number)) && !value.textFirst ? (
          <>
            <NumberView {...this.props} cellData={value.number}></NumberView>
            &nbsp;&nbsp;
          </>
        ) : null}
      </>
    );
  }
}
